package com.pengxh.app.realityshow.media;

import android.view.View;
import android.widget.Button;

import com.pengxh.app.multilib.base.BaseNormalActivity;
import com.pengxh.app.realityshow.R;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @description: TODO
 * @author: Pengxh
 * @email: 290677893@qq.com
 * @date: 2019/12/15 16:57
 */
public class AudioPublishActivity extends BaseNormalActivity implements View.OnClickListener, AudioCapture.OnAudioFrameCapturedListener {

    private static final String TAG = "AudioPublishActivity";

    @BindView(R.id.captureAudio)
    Button captureAudio;
    @BindView(R.id.playAudio)
    Button playAudio;
    private AudioCapture audioCapture;

    @Override
    public void initView() {
        setContentView(R.layout.activity_audio);
    }

    @Override
    public void initData() {

    }

    @Override
    public void initEvent() {
        audioCapture = new AudioCapture();
        audioCapture.setOnAudioFrameCapturedListener(this);
    }

    @OnClick({R.id.captureAudio, R.id.playAudio})
    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.captureAudio:
                if (!audioCapture.isCaptureStarted()) {
                    audioCapture.startCapture();
                    captureAudio.setText("停止采集");
                } else {
                    audioCapture.stopCapture();
                    captureAudio.setText("开始采集");
                }
                break;
            case R.id.playAudio:

                break;
            default:
                break;
        }
    }

    //编码前的回调
    @Override
    public void onAudioFrameCaptured(byte[] audioData) {
        //audioData是原始音频PCM数据

    }
}
